<html>
<head><meta charset="utf-8"><title>libm · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html">libm</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172750790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750790">(Aug 08 2019 at 09:31)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> I'm not sure which problem your libm PR solves. You mention that:</p>



<a name="172750795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750795">(Aug 08 2019 at 09:31)</a>:</h4>
<blockquote>
<p>ah, but that's not stable. this code is. that's why i did not also add a neon version, I'm only out to help out stable rust today.</p>
</blockquote>



<a name="172750798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750798">(Aug 08 2019 at 09:31)</a>:</h4>
<p>But stable Rust code can just call <code>f64::sqrt(x)</code></p>



<a name="172750805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750805">(Aug 08 2019 at 09:31)</a>:</h4>
<p>That will do the right thing, be it calling the C math library of the target, if it has one, or calling the <code>libm::sqrt</code> function if the target doesn't have one</p>



<a name="172750847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750847">(Aug 08 2019 at 09:32)</a>:</h4>
<p>in which case <code>libm::sqrt</code> gets pulled via compiler-builtins into libstd</p>



<a name="172750855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750855">(Aug 08 2019 at 09:32)</a>:</h4>
<p>and compiler-builtins can be compiled using nightly Rust</p>



<a name="172750866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750866">(Aug 08 2019 at 09:32)</a>:</h4>
<p>it is even linked to libcore</p>



<a name="172750952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750952">(Aug 08 2019 at 09:34)</a>:</h4>
<p>stable, core only code cannot</p>



<a name="172750990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172750990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172750990">(Aug 08 2019 at 09:35)</a>:</h4>
<p>have you tried ?</p>



<a name="172751001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751001">(Aug 08 2019 at 09:35)</a>:</h4>
<p>.......yes?</p>



<a name="172751090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751090">(Aug 08 2019 at 09:37)</a>:</h4>
<p>how ?</p>



<a name="172751092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751092">(Aug 08 2019 at 09:37)</a>:</h4>
<p>fn do_it(f: f32) -&gt; f32 {<br>
  f.sqrt()<br>
}</p>



<a name="172751096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751096">(Aug 08 2019 at 09:37)</a>:</h4>
<p>you need to write:</p>
<div class="codehilite"><pre><span></span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">sqrt</span><span class="p">(</span><span class="n">x</span>: <span class="kt">f64</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">f64</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="172751099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751099">(Aug 08 2019 at 09:37)</a>:</h4>
<p>sqrt(x)</p>



<a name="172751108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751108">(Aug 08 2019 at 09:37)</a>:</h4>
<p>(I think, I'm not sure of the symbol name)</p>



<a name="172751115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751115">(Aug 08 2019 at 09:37)</a>:</h4>
<p>should be the same name as the one in the libm crate</p>



<a name="172751157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751157">(Aug 08 2019 at 09:38)</a>:</h4>
<p>well that's pretty nifty but also _who would ever guess that_ :P</p>



<a name="172751168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751168">(Aug 08 2019 at 09:38)</a>:</h4>
<p>nobody</p>



<a name="172751175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751175">(Aug 08 2019 at 09:38)</a>:</h4>
<p>i was just pointing out that these are available for core only targets</p>



<a name="172751190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751190">(Aug 08 2019 at 09:38)</a>:</h4>
<p>because compiler-builtins is linked to those, and we expose the libm functions there using <code>#[no_mangle]</code></p>



<a name="172751206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751206">(Aug 08 2019 at 09:39)</a>:</h4>
<p>if some function isn't exposed for a target, you might want to send a PR to compiler-builtins to do that</p>



<a name="172751219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751219">(Aug 08 2019 at 09:39)</a>:</h4>
<p>if you want to allow <code>(x: f64).sqrt()</code> in libcore, you probably will need a PR to rust-lang/rust, putting that behind a feature gate, an RFC, etc.</p>



<a name="172751221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751221">(Aug 08 2019 at 09:39)</a>:</h4>
<p>well document everything you just said way better because me and everyone I know just literally puts libm as a dependency and then calls it manually</p>



<a name="172751274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751274">(Aug 08 2019 at 09:40)</a>:</h4>
<p>that's probably very bad</p>



<a name="172751275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751275">(Aug 08 2019 at 09:40)</a>:</h4>
<p>if you do that, llvm cannot optimize any math you do</p>



<a name="172751278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751278">(Aug 08 2019 at 09:40)</a>:</h4>
<p>I don't care specifically if it's a method or not</p>



<a name="172751279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751279">(Aug 08 2019 at 09:40)</a>:</h4>
<p>e.g. sqrt(0.0) is optimized by LLVM to 0.0</p>



<a name="172751282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751282">(Aug 08 2019 at 09:40)</a>:</h4>
<p>and yes, _now you see why i wanted the sse PR_</p>



<a name="172751283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751283">(Aug 08 2019 at 09:40)</a>:</h4>
<p>but if you call a libm::sqrt function, it won't optimize that away</p>



<a name="172751293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751293">(Aug 08 2019 at 09:41)</a>:</h4>
<p>(unless you use the core::intrinsic)</p>



<a name="172751302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751302">(Aug 08 2019 at 09:41)</a>:</h4>
<p>so using libm directly "can be done", but I don't know any good reason to actually do that in practice</p>



<a name="172751303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751303">(Aug 08 2019 at 09:41)</a>:</h4>
<p>well it's 340am, so I'll handle this another time</p>



<a name="172751306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751306">(Aug 08 2019 at 09:41)</a>:</h4>
<p>but this was illuminating</p>



<a name="172751344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751344">(Aug 08 2019 at 09:42)</a>:</h4>
<p>i think this might have been the way to do this, before libm was pulled into compiler-builtins</p>



<a name="172751348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751348">(Aug 08 2019 at 09:42)</a>:</h4>
<p>to support wasm32 math</p>



<a name="172751350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751350">(Aug 08 2019 at 09:42)</a>:</h4>
<p>in libstd</p>



<a name="172751355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751355">(Aug 08 2019 at 09:42)</a>:</h4>
<p>we should probably expose the f32 and 64 math methods from libcore, and tell people to just use that</p>



<a name="172751625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751625">(Aug 08 2019 at 09:48)</a>:</h4>
<p>yeah, yall should</p>



<a name="172751662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751662">(Aug 08 2019 at 09:50)</a>:</h4>
<p>PRs welcome I think</p>



<a name="172751731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751731">(Aug 08 2019 at 09:51)</a>:</h4>
<p>most of the work would probably be in removing the hacks that we currently use in libstd to add inherent methods to the f32 and f64 types, which are defined in libcore <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="172751739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751739">(Aug 08 2019 at 09:51)</a>:</h4>
<blockquote>
<p>because compiler-builtins is linked to those, and we expose the libm functions there using <code>#[no_mangle]</code></p>
</blockquote>
<p>ah that's why <code>extern "C" { fn ldexp(...) }</code> works?</p>



<a name="172751749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751749">(Aug 08 2019 at 09:51)</a>:</h4>
<p>yes, the functions exist in the binary</p>



<a name="172751752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751752">(Aug 08 2019 at 09:52)</a>:</h4>
<p>they are just not exposed in any form</p>



<a name="172751794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751794">(Aug 08 2019 at 09:52)</a>:</h4>
<p>if you link libstd, they are available on all targets</p>



<a name="172751798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751798">(Aug 08 2019 at 09:52)</a>:</h4>
<p>is that a stable guarantee?</p>



<a name="172751802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751802">(Aug 08 2019 at 09:52)</a>:</h4>
<p>either because the C library is linked, which has symbols for them, or because we provide symbols for them in compiler-builtins</p>



<a name="172751806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751806">(Aug 08 2019 at 09:52)</a>:</h4>
<p>no, otherwise we would expose the methods in libcore already</p>



<a name="172751811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751811">(Aug 08 2019 at 09:52)</a>:</h4>
<p>i don't think we'll ever guarantee anything about the symbol names</p>



<a name="172751821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751821">(Aug 08 2019 at 09:53)</a>:</h4>
<p>okay. in Miri we currently implement <code>ldexp</code> using <code>pow</code> to avoid having to rely on this...</p>



<a name="172751822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751822">(Aug 08 2019 at 09:53)</a>:</h4>
<p>we'll probably just expose the methods in libcore, and these should do the right thing</p>



<a name="172751827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751827">(Aug 08 2019 at 09:53)</a>:</h4>
<p>why?</p>



<a name="172751831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751831">(Aug 08 2019 at 09:53)</a>:</h4>
<p>to avoid having to rely on this</p>



<a name="172751833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751833">(Aug 08 2019 at 09:53)</a>:</h4>
<p>wait, do we have a ldexp method for f64 in libstd ?</p>



<a name="172751836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751836">(Aug 08 2019 at 09:53)</a>:</h4>
<p>if not, you can just add one I think</p>



<a name="172751887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751887">(Aug 08 2019 at 09:54)</a>:</h4>
<p>I mean all we saw was libcore tests using this <code>extern "C"</code> thing for <code>ldexp</code> and we were like "huh okay I guess that works but not sure if we should rely on it"</p>



<a name="172751892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751892">(Aug 08 2019 at 09:54)</a>:</h4>
<p>ah what ?</p>



<a name="172751895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751895">(Aug 08 2019 at 09:54)</a>:</h4>
<blockquote>
<p>wait, do we have a ldexp method for f64 in libstd ?</p>
</blockquote>
<p>no. it was removed, I think, when also a bunch of other more fancy math methods got nixed.</p>



<a name="172751896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751896">(Aug 08 2019 at 09:54)</a>:</h4>
<p>where are those tests lol</p>



<a name="172751899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751899">(Aug 08 2019 at 09:54)</a>:</h4>
<p><code>float_extra</code> or so</p>



<a name="172751903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751903">(Aug 08 2019 at 09:54)</a>:</h4>
<p>haha</p>



<a name="172751921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751921">(Aug 08 2019 at 09:55)</a>:</h4>
<blockquote>
<p>where are those tests lol</p>
</blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/04523404bcae5904fe29a54122040a7101f5c652/src/libcore/tests/num/flt2dec/mod.rs#L88" target="_blank" title="https://github.com/rust-lang/rust/blob/04523404bcae5904fe29a54122040a7101f5c652/src/libcore/tests/num/flt2dec/mod.rs#L88">https://github.com/rust-lang/rust/blob/04523404bcae5904fe29a54122040a7101f5c652/src/libcore/tests/num/flt2dec/mod.rs#L88</a></p>



<a name="172751974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751974">(Aug 08 2019 at 09:56)</a>:</h4>
<p>yeah</p>



<a name="172751979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751979">(Aug 08 2019 at 09:56)</a>:</h4>
<p>also see <a href="https://github.com/rust-lang/miri/issues/821" target="_blank" title="https://github.com/rust-lang/miri/issues/821">https://github.com/rust-lang/miri/issues/821</a> for the Miri side</p>



<a name="172751982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751982">(Aug 08 2019 at 09:56)</a>:</h4>
<p>i don't know if these are available for all targets that Rust currently supports</p>



<a name="172751984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751984">(Aug 08 2019 at 09:56)</a>:</h4>
<p>we don't run these tests for all of them</p>



<a name="172751986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751986">(Aug 08 2019 at 09:56)</a>:</h4>
<p>they are definetely available for a lot of targets</p>



<a name="172751987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751987">(Aug 08 2019 at 09:56)</a>:</h4>
<p>that link a C library</p>



<a name="172751997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172751997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172751997">(Aug 08 2019 at 09:57)</a>:</h4>
<p>making this play nice with no_std binaries might need some massaging</p>



<a name="172752011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752011">(Aug 08 2019 at 09:57)</a>:</h4>
<p>(we only want to expose symbols in compiler-builtins ifff no C library is linked, or the C library linked does not have symbols for these)</p>



<a name="172752060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752060">(Aug 08 2019 at 09:58)</a>:</h4>
<p>well if you notice them ever becoming available in a stable fashion (whether in libcore or libstd I don't care) please ping me ;)</p>



<a name="172752061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752061">(Aug 08 2019 at 09:58)</a>:</h4>
<p>this might mean that to support everything we might need to handle libm separately from the rest of compiler builtins</p>



<a name="172752076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752076">(Aug 08 2019 at 09:58)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> If miri requires libstd I think it is reasonable to assume that they are available</p>



<a name="172752094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752094">(Aug 08 2019 at 09:59)</a>:</h4>
<p>yeah it does, it requires librustc_mir^^</p>



<a name="172752154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752154">(Aug 08 2019 at 10:00)</a>:</h4>
<p>So I would only worry about them not being available if a user complains.</p>



<a name="172752169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752169">(Aug 08 2019 at 10:00)</a>:</h4>
<p>And then, it is probably worth it to fix this at the rust-lang/rust level</p>



<a name="172752244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752244">(Aug 08 2019 at 10:02)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="172752247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172752247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172752247">(Aug 08 2019 at 10:02)</a>:</h4>
<p>thanks</p>



<a name="172779532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172779532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172779532">(Aug 08 2019 at 16:21)</a>:</h4>
<p><code>ldexp</code> is a bit-manipulation function</p>



<a name="172779644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172779644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172779644">(Aug 08 2019 at 16:23)</a>:</h4>
<p>(<a href="https://github.com/nagisa/math.rs/blob/master/src/scalbln.rs" target="_blank" title="https://github.com/nagisa/math.rs/blob/master/src/scalbln.rs">https://github.com/nagisa/math.rs/blob/master/src/scalbln.rs</a> here’s a pure-rust implementation of the thing for you)</p>



<a name="172831591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172831591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172831591">(Aug 09 2019 at 07:33)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> does that mean we could reasonably have it host-independent in apfloat? :D</p>



<a name="172866962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172866962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172866962">(Aug 09 2019 at 16:47)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> we already have it though?</p>



<a name="172866986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172866986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172866986">(Aug 09 2019 at 16:47)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566">https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566</a></p>



<a name="172868751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172868751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172868751">(Aug 09 2019 at 17:07)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> <a href="https://travis-ci.org/Lokathor/lokacore/builds/569914277" target="_blank" title="https://travis-ci.org/Lokathor/lokacore/builds/569914277">https://travis-ci.org/Lokathor/lokacore/builds/569914277</a> we're down to just one build error this time.</p>
<p>Looks like the wasm32-unknown-unknown still misbehaves</p>



<a name="172869098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869098">(Aug 09 2019 at 17:11)</a>:</h4>
<p>yep: <a href="https://github.com/rust-lang-nursery/compiler-builtins/blob/master/src/math.rs#L25" target="_blank" title="https://github.com/rust-lang-nursery/compiler-builtins/blob/master/src/math.rs#L25">https://github.com/rust-lang-nursery/compiler-builtins/blob/master/src/math.rs#L25</a></p>



<a name="172869106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869106">(Aug 09 2019 at 17:11)</a>:</h4>
<p>note that for wasm32 we only link <code>libm</code> if the <code>target_os = wasi</code></p>



<a name="172869179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869179">(Aug 09 2019 at 17:12)</a>:</h4>
<p>you can just use the <code>libm</code> crate for that target, but if you have checked what it does</p>



<a name="172869192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869192">(Aug 09 2019 at 17:12)</a>:</h4>
<p>you are going to need nightly to properly compile it</p>



<a name="172869208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869208">(Aug 09 2019 at 17:12)</a>:</h4>
<p>otherwise <code>sqrtf32</code> won't lower to a <code>f32.sqrt</code> wasm instruction</p>



<a name="172869251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869251">(Aug 09 2019 at 17:13)</a>:</h4>
<p><a href="https://github.com/rust-lang-nursery/libm/blob/master/src/math/sqrtf.rs#L28" target="_blank" title="https://github.com/rust-lang-nursery/libm/blob/master/src/math/sqrtf.rs#L28">https://github.com/rust-lang-nursery/libm/blob/master/src/math/sqrtf.rs#L28</a></p>



<a name="172869280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869280">(Aug 09 2019 at 17:13)</a>:</h4>
<p>so that does the right thing, but only if you compile libm with nightly Rust and enable the unstable feature I think</p>



<a name="172869553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869553">(Aug 09 2019 at 17:14)</a>:</h4>
<p>the proper fix here is probably to link libm in compiler-builtins for the wasm32-unknown-unknown target</p>



<a name="172869626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869626">(Aug 09 2019 at 17:15)</a>:</h4>
<p>so that the symbols are available, but you are going to have to open an issue to discuss that first I think</p>



<a name="172869637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869637">(Aug 09 2019 at 17:15)</a>:</h4>
<p>or at least talk with alex and see if they think doing that would be ok</p>



<a name="172869649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172869649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172869649">(Aug 09 2019 at 17:15)</a>:</h4>
<p>calling the stable libm functions on wasm32 is just horrible</p>



<a name="172870573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870573">(Aug 09 2019 at 17:26)</a>:</h4>
<blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566">https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566</a></p>
</blockquote>
<p>so <code>scalb</code> is <code>ldexp</code>? Or <code>frexp</code> is?</p>



<a name="172870603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870603">(Aug 09 2019 at 17:26)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span>  how on Earth should one know that it's the same thing if it has a different name and isn't even documented to be the same thing?^^</p>



<a name="172870650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870650">(Aug 09 2019 at 17:27)</a>:</h4>
<p>I'm actually not sure lol</p>



<a name="172870667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870667">(Aug 09 2019 at 17:27)</a>:</h4>
<p>I just saw <span class="user-mention" data-user-id="123586">@nagisa</span>'s link having <code>scalbn</code> in it</p>



<a name="172870690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870690">(Aug 09 2019 at 17:27)</a>:</h4>
<p>okay <code>frexp</code> is something else, there's a C thing with the same name</p>



<a name="172870700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870700">(Aug 09 2019 at 17:27)</a>:</h4>
<p>I should've made that range shorter, frexp is not relevant (it basically lets you read the exponent)</p>



<a name="172870708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870708">(Aug 09 2019 at 17:27)</a>:</h4>
<p>so that leaves "are <code>ldexp</code> and <code>scalbn</code> the same thing?"</p>



<a name="172870712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870712">(Aug 09 2019 at 17:27)</a>:</h4>
<blockquote>
<blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566">https://github.com/rust-lang/rust/blob/master/src/librustc_apfloat/lib.rs#L553-L566</a></p>
</blockquote>
<p>so <code>scalb</code> is <code>ldexp</code>? Or <code>frexp</code> is?</p>
</blockquote>
<p>ldexp is scalbn</p>



<a name="172870773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870773">(Aug 09 2019 at 17:28)</a>:</h4>
<p>okay</p>



<a name="172870780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870780">(Aug 09 2019 at 17:28)</a>:</h4>
<p>well good thing that both names are just letter soup for me ;)</p>



<a name="172870792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870792">(Aug 09 2019 at 17:28)</a>:</h4>
<p><a href="https://github.com/nagisa/math.rs/blob/master/src/ldexp.rs#L6" target="_blank" title="https://github.com/nagisa/math.rs/blob/master/src/ldexp.rs#L6">https://github.com/nagisa/math.rs/blob/master/src/ldexp.rs#L6</a></p>



<a name="172870999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172870999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172870999">(Aug 09 2019 at 17:30)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> I saw that. It doesn't really <em>explain</em> anything though.^^</p>



<a name="172871002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871002">(Aug 09 2019 at 17:30)</a>:</h4>
<p>other than saying the two are the same, okay</p>



<a name="172871026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871026">(Aug 09 2019 at 17:31)</a>:</h4>
<p>Well, you could look at the source for muslc or something</p>



<a name="172871048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871048">(Aug 09 2019 at 17:31)</a>:</h4>
<p>(but it's not like I would have had any chance of finding that when I wonder about <code>ldexp</code> in apfloat)</p>



<a name="172871061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871061">(Aug 09 2019 at 17:31)</a>:</h4>
<p><a href="https://git.musl-libc.org/cgit/musl/tree/src/math/ldexp.c" target="_blank" title="https://git.musl-libc.org/cgit/musl/tree/src/math/ldexp.c">https://git.musl-libc.org/cgit/musl/tree/src/math/ldexp.c</a></p>



<a name="172871065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871065">(Aug 09 2019 at 17:31)</a>:</h4>
<p>uh, I dont usually start reading my libc source when I want to figure out if apfloat has some operation^^</p>



<a name="172871157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871157">(Aug 09 2019 at 17:32)</a>:</h4>
<p>I assumed <code>ldexp</code> was the canonical name everyone used for this. I think that's a reasonable assumption because it's not like most math functions have 2 entirely unrelated names. I was wrong though and you told me when I asked, so all is good. :D</p>



<a name="172871191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871191">(Aug 09 2019 at 17:32)</a>:</h4>
<p>Cruft is real.</p>



<a name="172871240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871240">(Aug 09 2019 at 17:33)</a>:</h4>
<p>and here's the docs PR: <a href="https://github.com/rust-lang/rust/pull/63416" target="_blank" title="https://github.com/rust-lang/rust/pull/63416">https://github.com/rust-lang/rust/pull/63416</a></p>



<a name="172871369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871369">(Aug 09 2019 at 17:34)</a>:</h4>
<p>nah <a href="https://en.cppreference.com/w/c/numeric/math/scalbn" target="_blank" title="https://en.cppreference.com/w/c/numeric/math/scalbn">https://en.cppreference.com/w/c/numeric/math/scalbn</a></p>



<a name="172871375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871375">(Aug 09 2019 at 17:34)</a>:</h4>
<p>both exist in C</p>



<a name="172871402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871402">(Aug 09 2019 at 17:35)</a>:</h4>
<p>also, I'd suggest getting docs into LLVM and backporting to Rust</p>



<a name="172871413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871413">(Aug 09 2019 at 17:35)</a>:</h4>
<p>for... complicated reasons</p>



<a name="172871423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871423">(Aug 09 2019 at 17:35)</a>:</h4>
<blockquote>
<p>On binary systems (where FLT_RADIX is 2), scalbn is equivalent to ldexp.</p>
</blockquote>



<a name="172871430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871430">(Aug 09 2019 at 17:35)</a>:</h4>
<blockquote>
<p>On binary systems (where FLT_RADIX is 2), scalbn is equivalent to ldexp.</p>
</blockquote>



<a name="172871431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871431">(Aug 09 2019 at 17:35)</a>:</h4>
<p>OMG</p>



<a name="172871438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871438">(Aug 09 2019 at 17:35)</a>:</h4>
<p>ah that is why they may differ</p>



<a name="172871440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871440">(Aug 09 2019 at 17:35)</a>:</h4>
<p>right</p>



<a name="172871450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871450">(Aug 09 2019 at 17:35)</a>:</h4>
<p>ldexp does something else on decimal</p>



<a name="172871459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871459">(Aug 09 2019 at 17:35)</a>:</h4>
<p>whereas the b(n?) in scalbn is binary</p>



<a name="172871553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871553">(Aug 09 2019 at 17:36)</a>:</h4>
<p>okay</p>



<a name="172871555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871555">(Aug 09 2019 at 17:36)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> so I should open an issue in the <code>compiler-builtins</code> repo about the missing sqrt?</p>



<a name="172871623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871623">(Aug 09 2019 at 17:37)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> more like, in general, whether all of them should be exposed for the target, or why are they only exposed for wasi ?</p>



<a name="172871792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172871792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172871792">(Aug 09 2019 at 17:38)</a>:</h4>
<p>On <strong>binary systems</strong> (where FLT_RADIX is 2), scalbn is equivalent to ldexp.</p>



<a name="172872046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172872046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172872046">(Aug 09 2019 at 17:41)</a>:</h4>
<p>so...</p>



<a name="172872075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172872075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172872075">(Aug 09 2019 at 17:41)</a>:</h4>
<p>we do support s390x-unknown-linux-gnu</p>



<a name="172872127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172872127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172872127">(Aug 09 2019 at 17:42)</a>:</h4>
<p>is FLT_RADIX == 16 there ?</p>



<a name="172872213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172872213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172872213">(Aug 09 2019 at 17:43)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> ^^^</p>



<a name="172872339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172872339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172872339">(Aug 09 2019 at 17:44)</a>:</h4>
<p><a href="https://github.com/llvm-mirror/clang/blob/master/test/Preprocessor/init.c#L7831" target="_blank" title="https://github.com/llvm-mirror/clang/blob/master/test/Preprocessor/init.c#L7831">https://github.com/llvm-mirror/clang/blob/master/test/Preprocessor/init.c#L7831</a> says it's 2</p>



<a name="172872736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172872736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172872736">(Aug 09 2019 at 17:48)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> so should I change the comment in <a href="https://github.com/rust-lang/rust/pull/63416" target="_blank" title="https://github.com/rust-lang/rust/pull/63416">https://github.com/rust-lang/rust/pull/63416</a> ? What should it say? I doubt we support non-binary systems...</p>



<a name="172873716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172873716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172873716">(Aug 09 2019 at 17:58)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> <a href="https://github.com/rust-lang-nursery/compiler-builtins/issues/308" target="_blank" title="https://github.com/rust-lang-nursery/compiler-builtins/issues/308">https://github.com/rust-lang-nursery/compiler-builtins/issues/308</a></p>



<a name="172874753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172874753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172874753">(Aug 09 2019 at 18:10)</a>:</h4>
<p>Does IEEE-754 not specify float radix?</p>



<a name="172874793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172874793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172874793">(Aug 09 2019 at 18:11)</a>:</h4>
<p>I’m pretty sure it does specify the binary representation of f32 and f64 at the very least.</p>



<a name="172874810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172874810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172874810">(Aug 09 2019 at 18:11)</a>:</h4>
<p>though again, I don’t have the whole spec in my head</p>



<a name="172875873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172875873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172875873">(Aug 09 2019 at 18:24)</a>:</h4>
<p>The binary rep is specified, yes</p>



<a name="172875933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172875933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172875933">(Aug 09 2019 at 18:25)</a>:</h4>
<p>IEEE 754 does specify only binary (and decimal) floats, but the world isn't (or at least hasn't always been) entirely composed of IEEE 754 implementations</p>



<a name="172876011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172876011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172876011">(Aug 09 2019 at 18:26)</a>:</h4>
<p>The base-16 radix used in the IBM 360/370, which was done for implementation compatibility with radix-10 decimal floating point, was a disaster for accurate computation. Numerical analysts demonstrated massive problems, including non-convergence of classical algorithms that <strong>always</strong> converge for any system approximating the rules of arithmetic. Thus non-decimal IEEE floating point uses radix 2.</p>



<a name="172876220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172876220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172876220">(Aug 09 2019 at 18:28)</a>:</h4>
<p>what does radix-16 FP do different than radix-2? I mean I guess the radix is somehow represented in base 16, but given that has to be mapped to binary eventually, what difference does that make?</p>



<a name="172879990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172879990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tom Phinney <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172879990">(Aug 09 2019 at 19:05)</a>:</h4>
<p>Radix-16 means that alignment shifts are in 4-bit nibbles rather than single bit. The easiest way to understand radix-16 is to consider decimal arithmetic with a 4-bit BCD representation for every digit and special coding (e.g., <code>0xA</code>, <code>0xB</code>) for sign bits. The operations are those you learned in school, shifting by 4-bit groups to maintain alignment. IIRC, even Newton-Raphson iteration of <code>sqrt</code> can fail to converge in the IBM 360/370 radix-16 floating point.</p>



<a name="172880545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172880545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172880545">(Aug 09 2019 at 19:13)</a>:</h4>
<blockquote>
<p>IEEE 754 does specify only binary (and decimal) floats, but the world isn't (or at least hasn't always been) entirely composed of IEEE 754 implementations</p>
</blockquote>
<p>I’m pretty sure we only support IEEE 754 floats in Rust, much like we only support two’s complement.</p>



<a name="172929316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/libm/near/172929316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/libm.html#172929316">(Aug 10 2019 at 15:42)</a>:</h4>
<blockquote>
<p>@gnzlbg <a href="https://github.com/rust-lang-nursery/compiler-builtins/issues/308" target="_blank" title="https://github.com/rust-lang-nursery/compiler-builtins/issues/308">https://github.com/rust-lang-nursery/compiler-builtins/issues/308</a></p>
</blockquote>
<p>yep, for wasm32 there is never a symbol, so one never needs to add anything to compiler-builtins</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>